package com.hj.chartdemo.viewmodel

import android.app.Dialog
import android.content.Context
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.hj.chartdemo.utils.MyIntent
import java.io.Serializable

/**
 * 默认基础ViewModel
 */
open class BaseViewModel : Serializable, ViewModel() {
    //用于Toast
    var toast = MutableLiveData<String>()
    //用于跳转
    var intent = MutableLiveData<MyIntent>()
    var finish = MutableLiveData<Boolean>()
    var finishWithBack = MutableLiveData<Int>()

    fun MyToast(text: String, warn: Boolean = true) {
//        if (warn) {
//            toast.postValue(text)
//        } else {
//            ToastUtil.toastShortMessage(text)
//        }
    }

    fun myStartActivity(intent: MyIntent) {
        this.intent.postValue(intent)
    }

    fun myFinish() {
        finish.postValue(true)
    }

    fun myFinish(result: Int) {
        finishWithBack.postValue(result)
    }


}
